<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>2.22 测试是否为数值型</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h2>测试是否为数值型</h2>
<div id='isNumber'>
</div>
<script type="text/javascript">
    window.onload = function(){
        var isNumber = function(_number){
                return typeof _number == "number";//
            },
                _number1 = "1",
                _number2 = 1,
                _number3 = 1.22,
                _number4 = null,
                _html = "";
        _html += isNumber(_number1) ? "_number1是数值型<br />" : "_number2不是数值型<br />";
        _html += isNumber(_number2) ? "_number2是数值型<br />" : "_number2不是数值型<br />";
        _html += isNumber(_number3) ? "_number3是数值型<br />" : "_number3不是数值型<br />";
        _html += isNumber(_number4) ? "_number4是数值型<br />" : "_number4不是数值型<br />";
        document.getElementById("isNumber").innerHTML = _html;
    };
</script>
</body>
</html>